package cn.ekuma.android.list;

import java.util.ArrayList;
import java.util.Map;

import cn.ekuma.android.shard.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ListViewInterceptorAdapter extends ArrayAdapter<Map<String, Object>> {
	private ArrayList<Map<String, Object>> array;

	public ListViewInterceptorAdapter(Context context, ArrayList<Map<String, Object>> objects) {
		super(context, R.layout.listview_interceptor_item, objects);
		this.array=objects;
	}

	public ArrayList<Map<String, Object>> getList() {
		return array;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		View row = convertView;
		if (row == null) {
			row = LayoutInflater.from(getContext()).inflate(R.layout.listview_interceptor_item, parent, false);
		}
		TextView label = (TextView) row.findViewById(R.id.title);
		label.setText(array.get(position).get("title").toString());
		TextView info = (TextView) row.findViewById(R.id.info);
		info.setText(array.get(position).get("info").toString());
		ImageView imageView = (ImageView) row.findViewById(R.id.img);
		imageView.setImageResource(Integer.valueOf(array.get(position)
				.get("img").toString()));
		return (row);
	}
}
